package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author :  LENOVO
 * 创建时间 : 2024/6/17 15:52
 */
@Mapper
public interface ShoppingCartMapper {
    // 查询购物车
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    // 向购物车中添加商品
    @Insert("insert into shopping_cart (name, user_id, dish_id, setmeal_id, dish_flavor, number, amount, image, create_time) " +
            " values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    // 修改购物车中的商品的数目
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(int number, Long id);

    // 根据id查询购物车
    @Select("select  * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> listGetById(Long id);

    // 清空购物车
    @Delete("delete  from shopping_cart  where user_id=#{userId}")
    void deleteByUserId(Long userId);

    // 根据id删除购物车
    @Delete("delete from shopping_cart  where dish_id=#{dishId} ")
    void deleteById(Long dishId);

    List<ShoppingCart> list1(ShoppingCart shoppingCart);

    void insertBatch(List<ShoppingCart> shoppingCartList);
}
